package com.foreverwin.jzymes.report.picking.controller;

import com.foreverwin.jzymes.common.util.CommonMethods;
import com.foreverwin.jzymes.framework.base.AjaxResult;
import com.foreverwin.jzymes.framework.base.BaseController;
import com.foreverwin.jzymes.framework.exception.BusinessException;
import com.foreverwin.jzymes.production.picking.domain.PickingBillLog;
import com.foreverwin.jzymes.production.picking.domain.PickingBom;
import com.foreverwin.jzymes.report.picking.service.IPickingReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/report/picking")
public class PickingReportController extends BaseController {

    @Autowired
    IPickingReportService pickingReportService;

    /**
     * 领料单报表查询
     * @param jsonMap
     * @return
     */
    @RequestMapping("/PickingReport")
    public  AjaxResult  PickingReport(@RequestParam Map<String,Object> jsonMap ){
        try{
            String site = CommonMethods.getSite();
            jsonMap.put( "site" , site );

            List<PickingBillLog> pickingBillLogs =
                    pickingReportService.selectPickingReport( jsonMap );

            return AjaxResult.returnSuccess().put("value" , pickingBillLogs);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }

    /**
     * 领料明细查询
     * @param jsonMap
     * @return
     */
    @RequestMapping("/findPickingBom")
    public  AjaxResult  findPickingBom(@RequestParam Map<String,Object> jsonMap ){
        try{

           List< PickingBom > pickingBoms = pickingReportService.findPickingBom( jsonMap );
            return AjaxResult.returnSuccess().put("value" , pickingBoms);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }

}
